<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增加或者修改</title>
    <link href="/summernotes/bootstrap1.css" rel="stylesheet">
    <link href="/summernotes/summernote.css" type="text/css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/admin/css/main.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/top.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/left.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/right.css"/>
    <script src="/admin/jquery/jquery.min.js"></script>
</head>
<body>
<div id="container">
    <div id="header">
        <h1 style="margin-top: -3px;">博客管理系统</h1>
        <div id="login_info">
            欢迎你：<?php
            echo session('admin_name');
            ?>
            <a href="/admin/login/logout/">退出登录</a>
        </div>
    </div>

    <div id="left">
        <ul>
            <li><a href="/admin/category/index/">分类管理</a></li>
            <li><a href="/admin/article/index/">文章管理</a></li>
            <li><a href="/admin/comment/index/">评论管理</a></li>
            <li><a href="/admin/admin/index/">管理员</a></li>
        </ul>
    </div>

    <div id="right">
        <div id="content">
            <div id="breadcrumb">
                <a href=index.php?c=article&a=index>首页</a> &gt;
                <a href=index.php?c=article&a=index>文章管理</a> &gt;
                <a href="index.php?c=article&a=add">增加文章</a>
            </div>
            <form action="/admin/article/editSave/" method="post">
                <table border="" cellspacing="" cellpadding="">
                    <input type="hidden" name="article_id" value="<?php echo $article['article_id']; ?>"/>
                    <tr>
                        <td>文章标题：</td>
                        <td><input type="text" name="article_title"
                                   value="<?php echo $article['article_title']; ?>"/></td>
                    </tr>
                    <!--<tr>-->
                    <!--    <td>评论总数：</td>-->
                    <!--    <td><input type="text" name="counts"-->
                    <!--               value="<?php echo $article['counts']; ?>"/></td>-->
                    <!--</tr>-->
                    <tr>
                        <td>所属分类：</td>
                        <td>
                            <select name="category_id">
                                <?php foreach ($categoryList as $row): ?>
                                    <option value="<?php echo $row['category_id']; ?>" <?php echo $article['category_id'] == $row['category_id'] ? 'selected="selected"' : ''; ?>>
                                        <?php echo $row['category_name'] ?>
                                    </option>
                                <?php endforeach; ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>文章简介：</td>
                        <td>
                            <textarea name="intro"><?php echo $article['intro']; ?></textarea>
                        </td>
                    </tr>
                    <tr>
                    <td>封面链接:</td>
                    <td><input type="text" name="cover_image" value="<?php echo $article['cover_image']; ?>" /></td>
                </tr>
                    <tr>
                        <td>文章内容：</td>
                        <td>
                            <textarea id="summernote" name="content"><?php echo $article['content']; ?></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="submit" value="提交" class="btn"/>
                            <input type="reset" value="重置" class="btn"/>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

</div>
</body>
</html>
<script src="/summernotes/jquery2.js" type="text/javascript"></script>
<script src="/summernotes/bootstrap2.js"></script>
<script src="/summernotes/summernote.js" type="text/javascript"></script>
<script src="/summernotes/summernote-zh-CN.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
      
        $('#summernote').summernote({
            lang:'zh-CN',
            callbacks: {
                onImageUpload: function(files) {
                    console.log(files);
                //上传图片到服务器，使用了formData对象，至于兼容性...据说对低版本IE不太友好
                    var form = document.getElementById("addForm");
                    console.log(form);
                    var formData = new FormData(form);
                    console.log(formData);
            formData.append('file',files[0]);
            
            $.ajax({
                url : 'https://linshiqiang.cn/uploaddemo/upload_file.php',//后台文件上传接口
                type : 'POST',
                data : formData,
                processData : false,
                contentType : false,
                    success : function(data) {
                    console.log(data);
                    // let imgSrc = "http://120.25.225.179/uploaddemo/upload/default.jpeg";
                    // console.log(imgSrc);
                    $('#summernote').summernote('insertImage',data,'img');
                },
            });
                    }
            }
        });

    });


</script>